package com.kantboot.business.ac.repository;

import com.kantboot.business.ac.domain.dto.BusAcRechargeProductOfSearchDTO;
import com.kantboot.business.ac.domain.entity.BusAcRechargeProductPhone;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface BusAcRechargeProductPhoneRepository
        extends JpaRepository<BusAcRechargeProductPhone, Long>
{

    @Query("""
    FROM BusAcRechargeProductPhone AS p
    WHERE 
    (:#{#param.typeId} IS NULL OR p.typeId = :#{#param.typeId})
    ORDER BY p.product.priority DESC
    """)
    Page<BusAcRechargeProductPhone> getBodyData(
            @Param("param")BusAcRechargeProductOfSearchDTO param,
            Pageable pageable
    );

}
